﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Fotobanka
{
    public partial class UkazGalerii : System.Web.UI.Page
    {
        PhotoManager pm;
        GalleriesManager gm;
        protected void Page_Load(object sender, EventArgs e)
        {
            pm = new PhotoManager();
            List<PhotoObject> pList = new List<PhotoObject>();
            if (!IsPostBack)
            {
                String gal_id = Request.Params["id_gal"];
                gm = new GalleriesManager();
                LoginInfo li = (LoginInfo)Session["logged_user_id"];
                List<int> gList = gm.SelectAssignedGalleriesIdForUser(li.Id);
                try
                {
                    if (gal_id != null && gList.Contains(Convert.ToInt32(gal_id)))
                    {

                        int id = Convert.ToInt32(gal_id);
                        pList = pm.SelectGalleryImages(id);

                        fotky_rep.DataSource = pList;
                        fotky_rep.DataBind();

                        Label1.Text = "Nalezeno fotek: " + pList.Count;
                    }
                    else
                    {
                        Label1.Text = "Chyba id";
                    }
                }
                catch (Exception ex)
                {
                    Label1.Text = ex.Message;
                }
            }
        }
    }
}
